<template>
	<view class="content display  displayColumn all_item width_750">
		<u-navbar @rightClick="rightClick" :autoBack="true" :placeholder="true">
			<template slot="left">
				<uni-icons type="left" color="#212121;" size="23" @click="back"></uni-icons>
			</template>
			<template slot="center">
				<text class="fontSize font_comm title">发票详情</text>
			</template>
		</u-navbar>
		
		<!-- 图片展示 -->
		<view class="fn_imgs display width_750 all_item " style="margin-top: 40rpx;">
			<view class="display width_699 fn_yulan all_item">
				<button class="fn_wode display all_item fontSize font_comm" @click="yulan">点击预览pdf</button>
			</view>
			<!-- <web-view :src="url"></web-view> -->
			<!-- <image class="image" src="https://dev.fapiao.com:19443/dzfp-web/pdf/download?request=dkiZcYM-ZbQmTT3hgQAfxiKGVMoqsgBDrhZnAzvBACT9jecZVrINgOZNUsJ3FXCRX-oEHUOm8h5MlcN58o4-2A__%5EccFcjCahcC" mode=""></image> -->
		</view>
		
		<view class="bottom_btn">
			<!-- <button class="fn_btn1 display fontSize font_comm all_item" @click="yulan">预览发票</button> -->
			<button class="fn_btn display fontSize font_comm all_item" @click="downPdf">下载至本地</button>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				filePath:'',
				urls:'https://dev.fapiao.com:19443/dzfp-web/pdf/download?request=dkiZcYM-ZbQmTT3hgQAfxiKGVMoqsgBDrhZnAzvBACT9jecZVrINgOZNUsJ3FXCRX-oEHUOm8h5MlcN58o4-2A__%5EccFcjCahcC'
			}
		},
		onLoad(options) {
			this.urls = options.pdfUrl
			let that = this;
			uni.downloadFile({
			  url: that.urls,
			  success: function (res) {
				  console.log(res)
			    // var filePath = res.tempFilePath;
				that.filePath = res.tempFilePath
			  }
			});
		},
		methods: {
			// 预览
			yulan(){
					let that = this;
				    uni.openDocument({
				      filePath: that.filePath,
				      showMenu: true,
				      success: function (res) {
				        console.log('打开文档成功');
				      }
				    });
			},
			// 下载
			downPdf(){
				let that = this
				uni.downloadFile({
				  url: that.urls,
				  success: function (res) {
					  console.log(res)
				    // var filePath = res.tempFilePath;
					that.filePath = res.tempFilePath
				    uni.openDocument({
				      filePath: that.filePath,
				      showMenu: true,
				      success: function (res) {
				        console.log('打开文档成功');
				      }
				    });
				  }
				});
			}
		}
	}
</script>

<style scoped lang="scss">
.title {
		font-weight: 600;
		font-size: 34rpx;
		color: #232323;
	}
	.image{
		width: 750rpx;
		height: 501rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}
	.fn_btn{
		width: 690rpx;
		height: 66rpx;
		background: #126BC9;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-weight: 600;
		font-size: 24rpx;
		color: #FFFFFF;
		
	}
	.fn_btn1{
		width: 690rpx;
		height: 66rpx;
		background: #126BC9;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-weight: 600;
		font-size: 24rpx;
		color: #FFFFFF;
		margin-bottom: 300rpx;
	}
	.bottom_btn{
		position: absolute;
		bottom: 128rpx;
	}
	.fn_yulan{
		width: 690rpx;
		height: 452rpx;
		background: #FFFFFF;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
	}
	.fn_wode{
		width: 642rpx;
		height: 120rpx;
		background: rgba(23,105,143,0.1);
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		// border: 2rpx solid;
		// border-image: linear-gradient(90deg, rgba(23, 105, 143, 1), rgba(173, 157, 246, 1), rgba(23, 105, 143, 1)) 2 2;
		font-weight: 600;
		font-size: 24rpx;
		color: #126BC9;
	}
</style>
